﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls">

    <ControlTemplate x:Key="FlipViewTemplate"
                     TargetType="{x:Type Controls:FlipView}">
        <Grid x:Name="root" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <Border Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}">
                <Border x:Name="PART_GlowBorder" BorderBrush="Transparent" BorderThickness="4">
                    <Grid>
                        <Grid x:Name="ControlGrid"
                          Panel.ZIndex="7">
                            <Button x:Name="PART_BackButton"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Left"
                                Style="{DynamicResource ControlButton}">
                                <Path Width="16"
                                  Height="18"
                                  Canvas.Left="15.9063"
                                  Canvas.Top="14.75"
                                  Stretch="Fill"
                                  Fill="{DynamicResource BlackBrush}"
                                  Data="F1 M 22.6563,23.75L 24.6563,25.75L 31.9063,32.75L 25.4063,32.75L 15.9063,23.75L 25.4063,14.75L 31.9063,14.75L 24.6563,21.75L 22.6563,23.75 Z " />
                            </Button>
                            <Button x:Name="PART_ForwardButton"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Right"
                                Style="{DynamicResource ControlButton}">
                                <Path Width="16"
                                  Height="18"
                                  Canvas.Left="15.9063"
                                  Canvas.Top="14.75"
                                  Stretch="Fill"
                                  Fill="{DynamicResource BlackBrush}"
                                  Data="F1 M 25.1563,23.75L 23.1563,21.75L 15.9063,14.75L 22.4063,14.75L 31.9063,23.75L 22.4063,32.75L 15.9063,32.75L 23.1563,25.75L 25.1563,23.75 Z " />
                            </Button>

                            <Button x:Name="PART_UpButton"
                                VerticalAlignment="Top"
                                HorizontalAlignment="Center"
                                Visibility="Hidden"
                                Style="{DynamicResource ControlButton}">
                                <Path Width="16"
                                  Height="18"
                                  Canvas.Left="15.9063"
                                  Canvas.Top="14.75"
                                  Stretch="Fill"
                                  Fill="{DynamicResource BlackBrush}"
                                  Data="F1 M 23.9063,22.5L 21.9063,24.5L 14.9063,31.75L 14.9063,25.25L 23.9063,15.75L 32.9063,25.25L 32.9063,31.75L 25.9063,24.5L 23.9063,22.5 Z " />
                            </Button>
                            <Button x:Name="PART_DownButton"
                                VerticalAlignment="Bottom"
                                HorizontalAlignment="Center"
                                Visibility="Hidden"
                                Style="{DynamicResource ControlButton}">
                                <Path Width="16"
                                  Height="18"
                                  Canvas.Left="15.9063"
                                  Canvas.Top="14.75"
                                  Stretch="Fill"
                                  Fill="{DynamicResource BlackBrush}"
                                  Data="F1 M 23.9063,25L 25.9063,23L 32.9063,15.75L 32.9063,22.25L 23.9062,31.75L 14.9063,22.25L 14.9063,15.75L 21.9063,23L 23.9063,25 Z " />
                            </Button>
                        </Grid>

                        <Grid x:Name="PART_BannerGrid"
                              VerticalAlignment="Bottom"
                              Height="0"
                              Panel.ZIndex="6"
                              Opacity="0.85"
                              Background="{DynamicResource BlackBrush}">
                            <Label Foreground="{DynamicResource WhiteBrush}"
                                   FontFamily="{TemplateBinding FontFamily}"
                                   FontSize="{TemplateBinding FontSize}"
                                   x:Name="PART_BannerLabel"
                                   IsTabStop="False" />
                        </Grid>

                        <Controls:TransitioningContentControl Content="{TemplateBinding SelectedItem}"
                                                          ContentTemplate="{TemplateBinding ItemTemplate}"
                                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                                          x:Name="PART_Presenter"
                                                          Panel.ZIndex="1"
                                                          IsTabStop="False"
                                                          HorizontalAlignment="Stretch"
                                                          VerticalAlignment="Stretch" />
                    </Grid>
                </Border>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger SourceName="root" Property="IsMouseOver" Value="True">
                <Trigger.Setters>
                    <Setter TargetName="PART_GlowBorder" Property="BorderBrush" Value="LightGray" />
                </Trigger.Setters>
            </Trigger>
            
            <Trigger Property="Orientation" Value="Vertical">
                <Trigger.Setters>
                    <Setter TargetName="PART_BackButton" Property="Visibility" Value="Hidden" />
                    <Setter TargetName="PART_ForwardButton" Property="Visibility" Value="Hidden" />

                    <Setter TargetName="PART_UpButton" Property="Visibility" Value="Visible" />
                    <Setter TargetName="PART_DownButton" Property="Visibility" Value="Visible" />
                </Trigger.Setters>
            </Trigger>
        </ControlTemplate.Triggers>
        <ControlTemplate.Resources>
            <Style TargetType="Button"
                   x:Key="ControlButton">
                <Setter Property="Height"
                        Value="30" />
                <Setter Property="Width"
                        Value="50" />
                <Setter Property="Opacity"
                        Value="0.4" />
                <Setter Property="Panel.ZIndex"
                        Value="5" />
                <Setter Property="IsTabStop"
                        Value="False" />
                <Setter Property="Focusable"
                        Value="True" />
                <Setter Property="Background"
                        Value="{DynamicResource WhiteBrush}" />
                <Setter Property="Foreground"
                        Value="{DynamicResource TextBrush}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border BorderBrush="{TemplateBinding Background}"
                                    Padding="1"
                                    CornerRadius="4">
                                <Grid Background="{TemplateBinding Background}">
                                    <Label FontFamily="Marlett"
                                           Foreground="{TemplateBinding Foreground}"
                                           FontSize="17"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center">
                                        <ContentPresenter ContentSource="Content" />
                                    </Label>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="Opacity"
                                            Value="1.0" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Storyboard x:Key="ShowBannerStoryboard">
                <DoubleAnimation To="30.0"
                                 AccelerationRatio="1.0"
                                 SpeedRatio="2.5"
                                 Storyboard.TargetProperty="Height" />
            </Storyboard>
            <Storyboard x:Key="HideBannerStoryboard">
                <DoubleAnimation To="0.0"
                                 AccelerationRatio="1.0"
                                 SpeedRatio="2.5"
                                 Storyboard.TargetProperty="Height" />
            </Storyboard>
            <Storyboard x:Key="HideControlStoryboard">
                <DoubleAnimation To="0.0"
                                 AccelerationRatio="1.0"
                                 SpeedRatio="2.5"
                                 Storyboard.TargetProperty="Opacity" />
            </Storyboard>
            <Storyboard x:Key="ShowControlStoryboard">
                <DoubleAnimation To="1.0"
                                 AccelerationRatio="1.0"
                                 SpeedRatio="2.5"
                                 Storyboard.TargetProperty="Opacity" />
            </Storyboard>
        </ControlTemplate.Resources>
    </ControlTemplate>
    <Style TargetType="{x:Type Controls:FlipView}">
        <Setter Property="MinHeight"
                Value="100" />
        <Setter Property="MinWidth"
                Value="100" />
        <Setter Property="FontSize"
                Value="16" />
        <Setter Property="Selector.IsSynchronizedWithCurrentItem"
                Value="True" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="Template"
                Value="{StaticResource FlipViewTemplate}" />
    </Style>
</ResourceDictionary>